/**
 * Created by cr. on 2017/8/29.
 * 用于拦截并记录访问日志
 */

const path = require("path"),
    mapper = require('error/i18nError'),
    TruError = require('error/truError');

Object.keys(mapper).map(m => {
    exports[`throw${m}`] = (...args) => {
        let err = new TruError('', mapper[m]["code"]);
        err['messageCode'] = m + " " + args.join(" ");
        err['i18n'] = mapper[m];
        err['i18n']['extra'] = " " + args.join(" ");
        throw err;
    };
});

exports.equal = error => error instanceof TruError;